# include <bits/stdc++.h>
using namespace std;

int n, k, hav, sum;

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(x < 8) x += hav, hav = 0;
        if(x > 8) hav += x - 8, x = 8;
        sum += x;
        if(sum >= k) {
            printf("%d\n", i);
            return 0;
        }
    }
    puts("-1\n");
    return 0;
}
